import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
/*   {
    title: '代码',
    align:"center",
    dataIndex: 'code'
   },*/
   {
    title: '月份',
    align:"center",
    dataIndex: 'datein'
   },
   {
    title: '货币代码',
    align:"center",
    dataIndex: 'cacode'
   },
   {
    title: '货币名称',
    align:"center",
    dataIndex: 'caname'
   },
   {
    title: '汇率',
    align:"center",
    dataIndex: 'rate',
   },
   {
    title: '本位币',
    align:"center",
    dataIndex: 'standard',
     customRender: ({ text }) => {
       if (!text || text == 1) {
         return '是';
       } else if (text == 0) {
         return '否';
       } else {
         return text;
       }
     },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "月份",
      field: 'datein',
      component: 'MonthPicker',
      colProps: {span: 6},
    componentProps:{
      showTime:false,
      valueFormat:"YYYY-MM",
      getPopupContainer: () => document.body,
    },
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '代码',
    field: 'code',
    component: 'InputNumber',
    show:false,
  },
  {
    label: '月份',
    field: 'datein',
    component: 'MonthPicker',
    componentProps:{
      showTime:false,
      valueFormat:"YYYY-MM",
      getPopupContainer: () => document.body,
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入月份!'},
          ];
     },
  },
  {
    label: '货币代码',
    field: 'cacode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入货币代码!'},
          ];
     },
  },
  {
    label: '货币名称',
    field: 'caname',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入货币名称!'},
          ];
     },
  },
  {
    label: '汇率',
    field: 'rate',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入汇率!'},
          ];
     },
  },
  {
    label: '本位币',
    field: 'standard',
    component: 'Select',
    componentProps:{
      options:[
        {label:"是",value:1},
        {label:"否",value:0},
      ]
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
